---
id: 65823dde36392f505a39f7c7
title: Passo 18
challengeType: 20
dashedName: step-18
---

# --description--

Finally, pass your `map()` call to the `sum()` function to obtain the total expenses and return the result.

# --hints--

You should return `sum(map(lambda expense: expense['amount'], expenses))` from your `total_expenses` function.

```js
({ test: () =>
  {
    const transformedCode = code.replace(/\r/g, "");        
    const foo = __helpers.python.getDef("\n"+transformedCode, "total_expenses");
    const {function_body} = foo;    
    assert(function_body.match(/^\s+return\s+sum\s*\(\s*map\s*\(\s*lambda\s+expense\s*:\s*expense\s*\[\s*("|')amount\1\s*\]\s*,\s*expenses\s*\)\s*\)/m));
  }
})
```

# --seed--

## --seed-contents--

```py
def add_expense(expenses, amount, category):
    expenses.append({'amount': amount, 'category': category})

def print_expenses(expenses):
    for expense in expenses:
        print(f'Amount: {expense["amount"]}, Category: {expense["category"]}')

--fcc-editable-region--
def total_expenses(expenses):
    map(lambda expense: expense['amount'], expenses)
--fcc-editable-region--

expenses = []
```
